<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #date {
            font-size: 30px;
        }
    </style>
</head>

<body>
    <p id="date"></p>
    <button onclick="go()">继续</button>
    <button onclick="stop()">停止</button>
</body>

<script>
    //在指定时间区间调用该函数 以毫秒数来调用的
    var i = setInterval('start()', 10);
    function start() {
        // 显示时间
        var date = new Date();
        var dateStr = '';
        //年
        dateStr += date.getFullYear() + '年';
        //月
        dateStr += date.getMonth() + '月';
        //日
        dateStr += date.getDate() + '日 ';
        //小时
        dateStr += date.getHours() + ':';
        //分钟
        dateStr += date.getMinutes() + ":";
        dateStr += date.getSeconds() + ":";
        dateStr += date.getMilliseconds();
        dateStr += date.getDay();
        //获取p标签的dom对象
        const p = document.getElementById('date');
        p.innerHTML = dateStr;
    }

    function go() {
        i = setInterval('start()', 10);
    }

    //停止时间
    function stop() {
        clearInterval(i);
    }
</script>

</html>